package cn.com.stary1993.kite.captcha.support.simple;


import cn.com.stary1993.kite.captcha.support.Captcha;
import cn.com.stary1993.kite.captcha.vo.CaptchaResponse;
import cn.com.stary1993.kite.captcha.vo.SimpleCaptchaVO;

import java.io.OutputStream;

/**
 * 简单图形验证码
 *
 * @author stary1993
 */
public abstract class SimpleImageCaptcha implements Captcha {

	public static final String BASE64_GIF = "data:image/gif;base64,";

	public static final String BASE64_JPG = "data:image/jpeg;base64,";

	public abstract CaptchaResponse<SimpleCaptchaVO> generate();

	/**
	 * 生成验证码
	 *
	 * @param type type类型
	 * @return CaptchaResponse<SimpleCaptchaVO>
	 */
	public abstract CaptchaResponse<SimpleCaptchaVO> generate(SimpleImageCaptchaType type);

	/**
	 * 生成验证码
	 *
	 * @param type      类型
	 * @param timestamp 时间戳
	 * @return CaptchaResponse<SimpleCaptchaVO>
	 */
	public abstract CaptchaResponse<SimpleCaptchaVO> generate(SimpleImageCaptchaType type, String timestamp);

	/**
	 * 输出流
	 *
	 * @param timestamp 时间戳
	 * @param out
	 */
	public abstract void out(String timestamp, OutputStream out);

	/**
	 * 输出流
	 *
	 * @param type      类型
	 * @param timestamp 时间戳
	 * @param out
	 */
	public abstract void out(SimpleImageCaptchaType type, String timestamp, OutputStream out);

	/**
	 * 验证
	 *
	 * @param inputCode 用户验证码
	 * @return
	 */
	public abstract boolean verify(String inputCode);

	/**
	 * 验证
	 *
	 * @param timestamp 时间戳
	 * @param inputCode 用户验证码
	 * @return
	 */
	public abstract boolean verify(String timestamp, String inputCode);

	/**
	 * 验证
	 *
	 * @param type      类型
	 * @param timestamp 时间戳
	 * @param inputCode 用户验证码
	 * @return
	 */
	public abstract boolean verify(SimpleImageCaptchaType type, String timestamp, String inputCode);

	/**
	 * 验证
	 *
	 * @param id
	 * @param type      类型
	 * @param timestamp 时间戳
	 * @param inputCode 用户验证码
	 * @return
	 */
	public abstract boolean verify(String id, SimpleImageCaptchaType type, String timestamp, String inputCode);

}
